package routes

import (
  "log"
  "go-scripts/controllers"
  "go-scripts/handler"
)

var indexController *controllers.IndexController = controllers.GetIndexController()

var routes map[string]func(*handler.Global) = make(map[string]func(*handler.Global))
//index请求
func init() {
  Register("GET /", indexController.Index)
  Register("GET /index", indexController.Index)
  Register("GET /index.html", indexController.Index)
  Register("POST /", indexController.Index)
  Register("POST /index", indexController.Index)
  Register("POST /index.html", indexController.Index)
}
//注册路由
func Register(path string, handleFunc func(*handler.Global))  {
  if _, exist := routes[path]; exist {
    log.Fatalf("path: %s is already registered", path)
    return
  }
  routes[path] = handleFunc
}

type AppRoute struct {

}

func (a *AppRoute) GetRoute() map[string]func(*handler.Global) {
  return routes
}